package com.voice.server;

import com.voice.core.connection.ConnectionManager;
import com.voice.server.channel.DefaultStreamListener;
import com.voice.server.channel.tcp.TCPServer;
import com.voice.server.properties.ServerProperties;
import com.wangjiacai.hqlQuery.EnableHqlQuery;
import com.wangjiacai.utils.EnableAliAsr;
import com.wangjiacai.utils.EnableAliTts;
import com.wangjiacai.utils.EnableWebUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;

import java.io.IOException;

@SpringBootApplication
@ServletComponentScan
@EnableHqlQuery
@EnableWebUtils
@EnableAliAsr
@EnableAliTts
@Slf4j
public class VoiceServerApplication {

    public static void main(String[] args) throws IOException {
        ConfigurableApplicationContext context=SpringApplication.run(VoiceServerApplication.class, args);
        DefaultStreamListener defaultStreamListener=context.getBean(DefaultStreamListener.class);
        ConnectionManager connectionManager=context.getBean(ConnectionManager.class);
        ServerProperties serverProperties=context.getBean(ServerProperties.class);
        TCPServer tcpServer = new TCPServer(serverProperties.getPort(),defaultStreamListener,connectionManager);
        tcpServer.start();
    }

}
